## Figure 5: Effect of Donations at Time t on Lobbying at Time t+k: -------------

## Instructions ----------------------------------------------------------------
# Step 1: Adjust DATA_DIR to where Data is is located
# Step 2: Adjust OUT_DIR to where Output folder is
# Step 3: Run entire script


## setup -----------------------------------------------------------------------
# clean slate
rm(list = ls())
# Need to install to read/use PanelEstimate Objects
# devtools::install_github("insongkim/PanelMatch",ref = "big_data_checks")

## library
library(dplyr)
library(data.table)
library(PanelMatch)

# set directory
MAIN_DIR <- "C:/Users/js.egb/Dropbox/campaign-lobby-paper/replication_package"

# set data folder
DATA_DIR <-  paste(MAIN_DIR, "/data/fig3/", sep = "")

# set output folder
OUT_DIR <- paste(MAIN_DIR, "/output/", sep = "")

# file to be read in
# file_in <- paste0(DATA_DIR, "don_lob_all_ind_20210203.csv") # file to be input


pdf(file = file.path(OUT_DIR, paste0("figure_3.pdf")), height = 7, width = 14) # "msets_plot.pdf"
par(font.lab = 2, cex.lab = 2.3, cex.axis = 1.8, cex.main = 2.5, mar = c(6,7,5,3), las = 1, mfrow = c(1,2))



# Senate
load(file.path(DATA_DIR, "MSets_manuf_ann_senate_maha_AnyDon_AnyLob"))
msets.maha <- Matches.lobby$att

plot(msets.maha, main = "Senate", breaks = 40, ylab = "", xlab = "", ylim = c(0, 600))
mtext(side = 1, "Matched Set Size", line = 4, cex = 2.3)
title(ylab = "Frequency", line = 5, font.lab = 1)
rm(Matches.lobby)



# House
load(file.path(DATA_DIR, "MSets_manuf_ann_house_maha_AnyDon_AnyLob"))

msets.maha <- Matches.lobby$att
plot(msets.maha, main = "House", breaks = 40, ylab = "", xlab = "",  ylim = c(0, 600))
mtext(side = 1, "Matched Set Size", line = 4, cex = 2.3)
# title(ylab = "Frequency", line = 4, font.lab = 1)
rm(Matches.lobby)
dev.off()
